//
//  HomeViewController.swift
//  MySwift
//
//  Created by nadyboy on 2018/12/13.
//  Copyright © 2018年 hjh. All rights reserved.
//

import UIKit

class HomeViewController: BaseViewController{
     let cellId = "cellId"
    let ScreenWidth = UIScreen.main.bounds.width
    let ScreenHeight = UIScreen.main.bounds.height
    
    
    var tableView:UITableView?
    override func viewDidLoad() {
        super.viewDidLoad()
        
        tableView = UITableView(frame:CGRect(x: 0, y: 0, width: ScreenWidth, height: ScreenHeight), style: .plain)
        tableView?.delegate = self
        tableView?.dataSource = self
        tableView?.register(HomeTableViewCell.classForCoder(), forCellReuseIdentifier: cellId)
        self.view.addSubview(tableView!)
        
        // Do any additional setup after loading the view.
    }


}

extension HomeViewController:UITableViewDataSource,UITableViewDelegate{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 10
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath) as! HomeTableViewCell
        cell.titleLabel.text = "zhangjing"
        return cell
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 200;
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        let vc = DetailViewController()
        vc.title = "detail"
        self.navigationController?.pushViewController(vc, animated: true)
    }
    
}

